// ./mongodb/manager/article/articleModel.js
const mongoose = require("mongoose");

const articleSchema = new mongoose.Schema(
  {
    title: { type: String, required: true, unique: true }, // 文章标题
    content: { type: String, required: true }, // 文章内容
    sort: { type: String, enum: ["动态", "文化", "保护"], required: true }, // 文章分类标签
    origin: { type: String, required: true }, // 文章所属组织
    town: { type: String, required: true }, // 文章所属小镇
    deleted: { type: Boolean, default: false }, // 删除标志
    isPublished: { type: Boolean, default: false }, // 发布状态，默认为未发布
  },
  {
    timestamps: true, // 使用默认的 createdAt 和 updatedAt 字段
  },
);

const ArticleModel = mongoose.model("Article", articleSchema);
module.exports = ArticleModel;
